home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 483 / mkrscsrc / dialogs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-26  |  10.1 KB  |  383 lines

  1. #include "stdio.h"
  2. #include "gemdefs.h"
  3. #include "obdefs.h"
  4. #include "osbind.h"
  5. #include "mkrsc.h"
  6. #include "globals.h"
  7.  
  8. do_buttont(result)
  9.     int result;
  10. {
  11.     int nstate, nflag, button, i;
  12.     OBJECT    *objptr;
  13.     TEDINFO    *tiptr1;
  14.     TEDINFO *tiptr2;
  15.     char *chptr, savestr[80];
  16.  
  17.     objptr = thefrontwin->inwindow->objt;
  18.     tiptr1 = (TEDINFO *)(buttont[BEDITSTR].ob_spec);
  19.  
  20. /* chptr points to the string in the button/string/title object    */
  21.  
  22.     chptr  = (char *)(objptr[result].ob_spec);
  23.     strcpy(savestr,chptr);    
  24.     tiptr1->te_ptext = chptr;
  25.     tiptr1->te_txtlen = 36;
  26.     
  27. /* deselect all buttons in buttont    */    
  28.     
  29.     for(i=0;i<16;i++)
  30.         buttont[i].ob_state &= ~SELECTED;
  31.         
  32. /* set appropriate selection of objects in buttont for current object    */
  33.  
  34.     i = objptr[result].ob_state;
  35.     if(i & 2)
  36.         buttont[BCROSSED].ob_state ^= SELECTED;
  37.     if(i & 4)
  38.         buttont[BCHECKED].ob_state ^= SELECTED;
  39.     if(i & 8)
  40.         buttont[BDISABLE].ob_state ^= SELECTED;
  41.     if(i & 16)
  42.         buttont[BOUTLINE].ob_state ^= SELECTED;
  43.     if(i & 32)
  44.         buttont[BSHADOW].ob_state ^= SELECTED;
  45.  
  46.     i = objptr[result].ob_flags;
  47.     if(i & 1)
  48.         buttont[BSELECT].ob_state ^= SELECTED;
  49.     if(i & 2)
  50.         buttont[BDEFAULT].ob_state ^= SELECTED;
  51.     if(i & 4)
  52.         buttont[BEXIT].ob_state ^= SELECTED;
  53.     if(i & 8)
  54.         buttont[BEDITABL].ob_state ^= SELECTED;
  55.     if(i & 16)
  56.         buttont[BRADBUT].ob_state ^= SELECTED;
  57.     if(i & 0x40)
  58.         buttont[BTOUCHEX].ob_state ^= SELECTED;
  59.         
  60.     button = do_dialog(buttont,0);
  61.     if (button == BCANCEL)
  62.     {    strcpy(chptr,savestr);
  63.         return;
  64.     }
  65.     
  66.     nstate = (buttont[BCROSSED].ob_state & 1)*2
  67.                 + (buttont[BCHECKED].ob_state & 1)*4
  68.                 + (buttont[BDISABLE].ob_state & 1)*8
  69.                 + (buttont[BOUTLINE].ob_state & 1)*16
  70.                 + (buttont[BSHADOW].ob_state & 1)*32;
  71.  
  72.     objptr[result].ob_state = nstate;
  73.  
  74.     nflag =    (buttont[BSELECT].ob_state & 1)
  75.                 + (buttont[BDEFAULT].ob_state & 1)*2
  76.                 + (buttont[BEXIT].ob_state & 1)*4
  77.                 + (buttont[BEDITABL].ob_state & 1)*8
  78.                 + (buttont[BRADBUT].ob_state & 1)*16
  79.                 + (buttont[ BTOUCHEX].ob_state & 1)*0x40;
  80.  
  81.     objptr[result].ob_flags = nflag;
  82.  
  83.     if(objptr[result].ob_width < (gl_wchar * strlen(chptr)))
  84.         objptr[result].ob_width = (gl_wchar * strlen(chptr));
  85.     
  86. }
  87.  
  88. do_tist(result)
  89.     int result;
  90. {    
  91.     TEDINFO *tiptr1, *tiptr2;
  92.     TEDINFO *txtptr, *tmpptr, *valptr;
  93.     OBJECT    *objptr;
  94.     char svetxt[80], svetmp[80], sveval[80];
  95.     int i, button, nstate, nflag;
  96.     char *strptr;
  97.     COLORINT cint;
  98.     int cx, cy, cw, ch;  /* dialog box dimensions  */
  99.     int thick, minw;
  100.  
  101. /* define some pointers    */
  102.  
  103.     txtptr = (TEDINFO *)(tist[TTEXT].ob_spec);
  104.     tmpptr = (TEDINFO *)(tist[TTMPLT].ob_spec);
  105.     valptr = (TEDINFO *)(tist[TVALID].ob_spec);
  106.     
  107.     objptr = thefrontwin->inwindow->objt;
  108.     tiptr2 = (TEDINFO *)(objptr[result].ob_spec);
  109.     tiptr1 = (TEDINFO *)(tist[TIEXAMPL].ob_spec);
  110.     tiptr1->te_color = tiptr2->te_color;
  111.     tiptr1->te_thickness = tiptr2->te_thickness;
  112.     thick = tiptr2->te_thickness;
  113.     if(thick & 0x80)
  114.         thick |= 0xFF00;
  115.     strptr = tist[TILINE].ob_spec;
  116.     sprintf(strptr,"%4d",thick);
  117.  
  118.  
  119. /* save the original strings in case of a CANCEL    */
  120.  
  121.     strcpy(svetxt,tiptr2->te_ptext);
  122.     strcpy(svetmp,tiptr2->te_ptmplt);
  123.     strcpy(sveval,tiptr2->te_pvalid);
  124.     
  125. /*    point the dialog box text pointers to the strings to edit    */
  126.  
  127.     txtptr->te_ptext = tiptr2->te_ptext;
  128.     tmpptr->te_ptext = tiptr2->te_ptmplt;
  129.     valptr->te_ptext = tiptr2->te_pvalid;
  130.  
  131.     txtptr->te_txtlen = 40;
  132.     tmpptr->te_txtlen = 40;
  133.     valptr->te_tmplen = 40;
  134.     txtptr->te_tmplen = 40;
  135.     tmpptr->te_tmplen = 40;
  136.     valptr->te_txtlen = 40;
  137.  
  138.     
  139. /* deselect selectable objects in the tist dialog box    */
  140.  
  141.     for(i=0;i<15;i++)
  142.         tist[i].ob_state &= ~SELECTED;
  143.  
  144. /* set the state of other selectable objects in tist appropriately    */
  145.  
  146.     cint.whole = tiptr2->te_color;
  147.  
  148.     strptr = tist[TIBDCOLO].ob_spec;
  149.     sprintf(strptr,"%02d",(int)cint.part.bdcolor);
  150.     strptr = tist[TITCOLOR].ob_spec;
  151.     sprintf(strptr,"%02d",(int)cint.part.tcolor);
  152.     if((int)cint.part.wrmode)
  153.     {    tist[TIMR].ob_state |= SELECTED;
  154.         tist[TIMT].ob_state &= ~SELECTED;
  155.     }
  156.     else
  157.     {    tist[TIMT].ob_state |= SELECTED;
  158.         tist[TIMR].ob_state &= ~SELECTED;
  159.     }
  160.     strptr = tist[TIFILL].ob_spec;
  161.     sprintf(strptr,"%02d",(int)cint.part.fillmode);
  162.     strptr = tist[TIBGCOLO].ob_spec;
  163.     sprintf(strptr,"%02d",(int)cint.part.bgcolor);
  164.  
  165.     if(tiptr2->te_font == 5)
  166.     {    tist[TIFS].ob_state |= SELECTED;
  167.         tist[TIFL].ob_state &= ~SELECTED;
  168.     }
  169.     else
  170.     {    tist[TIFL].ob_state |= SELECTED;
  171.         tist[TIFS].ob_state &= ~SELECTED;
  172.     }
  173.     switch (tiptr2->te_just)
  174.     {    
  175.         case 0 :     tist[TIJL].ob_state |= SELECTED;
  176.                     tist[TIJC].ob_state &= ~SELECTED;
  177.                     tist[TIJR].ob_state &= ~SELECTED;
  178.                     break;
  179.         case 1 :     tist[TIJR].ob_state |= SELECTED;
  180.                     tist[TIJL].ob_state &= ~SELECTED;
  181.                     tist[TIJC].ob_state &= ~SELECTED;
  182.                     break;
  183.         case 2 :     tist[TIJC].ob_state |= SELECTED;
  184.                     tist[TIJR].ob_state &= ~SELECTED;
  185.                     tist[TIJL].ob_state &= ~SELECTED;
  186.                     break;
  187.     }
  188.  
  189.  
  190.     i = objptr[result].ob_state;
  191.     if(i & 2)
  192.         tist[TCROSS].ob_state ^= SELECTED;
  193.     if(i & 4)
  194.         tist[TCHECKED].ob_state ^= SELECTED;
  195.     if(i & 8)
  196.         tist[TDISABLE].ob_state ^= SELECTED;
  197.     if(i & 16)
  198.         tist[TOUTLINE].ob_state ^= SELECTED;
  199.     if(i & 32)
  200.         tist[TSHADOW].ob_state ^= SELECTED;
  201.     
  202.     i = objptr[result].ob_flags;
  203.     if(i & 1)
  204.         tist[TSELECT].ob_state ^= SELECTED;
  205.     if(i & 2)
  206.         tist[TDEFAULT].ob_state ^= SELECTED;
  207.     if(i & 4)
  208.         tist[TEXIT].ob_state ^= SELECTED;
  209.     if(i & 8)
  210.         tist[TEDITABL].ob_state ^= SELECTED;
  211.     if(i & 16)
  212.         tist[TRADBUT].ob_state ^= SELECTED;
  213.     if(i & 0x40)
  214.         tist[TTOUCHEX].ob_state ^= SELECTED;
  215.         
  216. /* now draw the dialog box and process the selected objects    */
  217.         
  218.     form_center(tist, &cx, &cy, &cw, &ch);
  219.     form_dial(FMD_START, 0, 0, 0, 0, cx, cy, cw, ch);
  220.     objc_draw(tist, 0, 10, cx, cy, cw, ch);
  221.     button = 0;
  222.     while( (button != TOK) && (button != TCANCEL) ) 
  223.     {    button = form_do(tist, 0);
  224.         switch (button)
  225.         {
  226.         case TIBDUP    :
  227.             strptr = tist[TIBDCOLO].ob_spec;
  228.             if(cint.part.bdcolor <15)
  229.                 cint.part.bdcolor++;
  230.             sprintf(strptr,"%02d",(int)cint.part.bdcolor);
  231.             tist[TIBDUP].ob_state &= ~SELECTED;
  232.             objc_draw(tist,TIBDBOX,2,cx,cy,cw,ch);
  233.             break;
  234.         case TIBDDWN    :
  235.             strptr = tist[TIBDCOLO].ob_spec;
  236.             if(cint.part.bdcolor >0)
  237.                 cint.part.bdcolor--;
  238.             sprintf(strptr,"%02d",(int)cint.part.bdcolor);
  239.             tist[TIBDDWN].ob_state &= ~SELECTED;
  240.             objc_draw(tist,TIBDBOX,2,cx,cy,cw,ch);
  241.             break;
  242.         case TIFDWN    :
  243.             strptr = tist[TIFILL].ob_spec;
  244.             if(cint.part.fillmode >0)
  245.                 cint.part.fillmode--;
  246.             sprintf(strptr,"%02d",(int)cint.part.fillmode);
  247.             tist[TIFDWN].ob_state &= ~SELECTED;
  248.             objc_draw(tist,TIFBOX,2,cx,cy,cw,ch);
  249.             break;
  250.         case TIFUP    :
  251.             strptr = tist[TIFILL].ob_spec;
  252.             if(cint.part.fillmode < 7)
  253.                 cint.part.fillmode++;
  254.             sprintf(strptr,"%02d",(int)cint.part.fillmode);
  255.             tist[TIFUP].ob_state &= ~SELECTED;
  256.             objc_draw(tist,TIFBOX,2,cx,cy,cw,ch);
  257.             break;
  258.         case TITDWN    :
  259.             strptr = tist[TITCOLOR].ob_spec;
  260.             if(cint.part.tcolor >0)
  261.                 cint.part.tcolor--;
  262.             sprintf(strptr,"%02d",(int)cint.part.tcolor);
  263.             tist[TITDWN].ob_state &= ~SELECTED;
  264.             objc_draw(tist,TITBOX,2,cx,cy,cw,ch);
  265.             break;
  266.         case TITUP    :
  267.             strptr = tist[TITCOLOR].ob_spec;
  268.             if(cint.part.tcolor < 15)
  269.                 cint.part.tcolor++;
  270.             sprintf(strptr,"%02d",(int)cint.part.tcolor);
  271.             tist[TITUP].ob_state &= ~SELECTED;
  272.             objc_draw(tist,TITBOX,2,cx,cy,cw,ch);
  273.             break;
  274.         case TIBGDWN    :
  275.             strptr = tist[TIBGCOLO].ob_spec;
  276.             if(cint.part.bgcolor >0)
  277.                 cint.part.bgcolor--;
  278.             sprintf(strptr,"%02d",(int)cint.part.bgcolor);
  279.             tist[TIBGDWN].ob_state &= ~SELECTED;
  280.             objc_draw(tist,TIBGBOX,2,cx,cy,cw,ch);
  281.             break;
  282.         case TIBGUP    :
  283.             strptr = tist[TIBGCOLO].ob_spec;
  284.             if(cint.part.bgcolor < 15)
  285.                 cint.part.bgcolor++;
  286.             sprintf(strptr,"%02d",(int)cint.part.bgcolor);
  287.             tist[TIBGUP].ob_state &= ~SELECTED;
  288.             objc_draw(tist,TIBGBOX,2,cx,cy,cw,ch);
  289.             break;
  290.         case TILUP    :
  291.             strptr = tist[TILINE].ob_spec;
  292.             if(thick < 25)
  293.                 thick += 1;
  294.             sprintf(strptr,"%4d",thick);
  295.             tist[TILUP].ob_state &= ~SELECTED;
  296.             objc_draw(tist,TILBOX,2,cx,cy,cw,ch);
  297.             break;
  298.         case TILDWN    :
  299.             strptr = tist[TILINE].ob_spec;
  300.             if(thick > -25)
  301.                 thick -= 1;
  302.             sprintf(strptr,"%4d",thick);
  303.             tist[TILDWN].ob_state &= ~SELECTED;
  304.             objc_draw(tist,TILBOX,2,cx,cy,cw,ch);
  305.             break;
  306.         }
  307.  
  308.     strptr = tist[TILINE].ob_spec;
  309.     sscanf(strptr,"%d",&thick);
  310.  
  311.     strptr = tist[TIBDCOLO].ob_spec;
  312.     cint.part.bdcolor = atoi(strptr);
  313.     strptr = tist[TITCOLOR].ob_spec;
  314.     cint.part.tcolor = atoi(strptr);
  315.  
  316.     if(tist[TIMR].ob_state & SELECTED)
  317.         cint.part.wrmode = 1;
  318.     else
  319.         cint.part.wrmode = 0;
  320.  
  321.     strptr = tist[TIFILL].ob_spec;
  322.     cint.part.fillmode = atoi(strptr);
  323.     strptr = tist[TIBGCOLO].ob_spec;
  324.     cint.part.bgcolor = atoi(strptr);
  325.  
  326.     tiptr1->te_color = cint.whole;
  327.     tiptr1->te_thickness = thick & 0xFF;
  328.  
  329.     if(tist[TIFS].ob_state & SELECTED)
  330.         tiptr1->te_font = 5;
  331.     else
  332.         tiptr1->te_font = 3;
  333.  
  334.     if(tist[TIJL].ob_state & SELECTED)
  335.         tiptr1->te_just = 0;
  336.     else if(tist[TIJC].ob_state & SELECTED)
  337.         tiptr1->te_just = 2;
  338.     else
  339.         tiptr1->te_just = 1;
  340.  
  341.     nstate = (tist[TCROSS].ob_state & 1)*2
  342.                 + (tist[TCHECKED].ob_state & 1)*4
  343.                 + (tist[TDISABLE].ob_state & 1)*8
  344.                 + (tist[TOUTLINE].ob_state & 1)*16
  345.                 + (tist[TSHADOW].ob_state & 1)*32;
  346.  
  347.     nflag =    (tist[TSELECT].ob_state & 1)
  348.                 + (tist[TDEFAULT].ob_state & 1)*2
  349.                 + (tist[TEXIT].ob_state & 1)*4
  350.                 + (tist[TEDITABL].ob_state & 1)*8
  351.                 + (tist[TRADBUT].ob_state & 1)*16
  352.                 + (tist[TTOUCHEX].ob_state & 1)*0x40;
  353.  
  354.     objc_draw(tist,TIEXBOX,2,cx,cy,cw,ch);
  355.     }
  356.         form_dial(FMD_FINISH, 0, 0, 0, 0, cx, cy, cw, ch);
  357.  
  358.     if (button == TCANCEL)
  359.     {    strcpy(tiptr2->te_ptext,svetxt);
  360.         strcpy(tiptr2->te_ptmplt,svetmp);
  361.         strcpy(tiptr2->te_pvalid,sveval);
  362.         return;
  363.     }
  364.     
  365.     objptr[result].ob_state = nstate;
  366.     objptr[result].ob_flags = nflag;
  367.     tiptr2->te_just = tiptr1->te_just;
  368.     tiptr2->te_font = tiptr1->te_font;
  369.     tiptr2->te_color = cint.whole;
  370.     tiptr2->te_thickness = thick & 0xFF;
  371.  
  372.  
  373.     minw = max(gl_wchar * strlen(tiptr2->te_ptmplt),gl_wchar);
  374.     minw = max(gl_wchar * strlen(tiptr2->te_ptext),minw);
  375.     if(objptr[result].ob_width < minw)
  376.         objptr[result].ob_width = minw;
  377.  
  378.     tiptr2->te_tmplen = strlen(tiptr2->te_ptmplt);
  379.     tiptr2->te_txtlen = strlen(tiptr2->te_pvalid);
  380.  
  381. }
  382.  
  383.